/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package interfaces;

import entities.Article;
import entities.ArticleState;
import entities.Category;
import java.util.Date;
import java.util.List;
import javax.ejb.EJBException;
import javax.ejb.Local;

/**
 *
 * @author Thibault
 */
@Local
public interface ArticleInterface {

    /**
     * Add a new article in database.
     *
     * @param article the article to add at database.
     */
    public void createArticle(Article article);

    /**
     * Find an Article using his identifiant
     *
     * @param id id of searching article.
     * @throws EJBException if article doesn't exist.
     * @return The article corresponding to id, throws <b>EJBException</b> if
     * doesn't exist.
     */
    public Article findById(long id) throws EJBException;

    /**
     * Delete an article from database.
     *
     * @throws EJBException if article id doesn't exist.
     * @param id Identifiant of article to delete.
     */
    public void removeArticle(long id) throws EJBException;

    /**
     * Update an article from database.
     *
     * @param article the article to update.
     */
    public void updateArticle(Article article);

    /**
     * Get all of article create by a user.
     *
     * @param id id of user searchin articles.
     * @return a list of article.
     */
    public List<Article> getListArticleForUserId(Long id);

    /**
     * Get all of article create by a user in a precised state.
     *
     * @param id id of user searching articles.
     * @param state state of searched article.
     * @return a list of article.
     */
    public List<Article> getListArticleForUserIdAndState(Long id, ArticleState state);

    /**
     * Set an article from status 'forSale' to status 'canceled'.
     *
     * @param selectedArticle the article to change.
     * @throws IllegalArgumentException if the article has not the forSale
     * status.
     */
    public void cancelArticle(Article selectedArticle) throws IllegalArgumentException;

    /**
     * Set an article from status 'canceled' to status 'forSale'.
     *
     * @param selectedArticle the article to change.
     * @param endAuction the new end of auction for the article;
     * @throws IllegalArgumentException if the article has not the cancel
     * status.
     */
    public void reSaleArticle(Article selectedArticle, Date endAuction) throws IllegalArgumentException;

    /**
     * Set an article from status 'forSale' to status 'sold'.
     *
     * @param selectedArticle the article to change.
     * @throws IllegalArgumentException if the article has not the forSale
     * status.
     */
    public void acceptAuction(Article selectedArticle) throws IllegalArgumentException;

    /**
     * Search an article using his name.
     *
     * @param keyWord String in the name of the article.
     * @return All articles containing the string parameter.
     */
    public List<Article> searchByName(String keyWord);

    /**
     * Search articles using name and categories
     *
     * @param keyWord String in the name of articles.
     * @param categories categories of artcles.
     * @return List of articles with categories parameter and keyword in his
     * name.
     */
    public List<Article> searchByNameAndCategories(String keyWord, List<Category> categories);
}
